#include <stdlib.h>
#include "mime.h"
#include "configuration.h"

extern configuration_t mime_types;

const char *get_mime_type (const char *filename, size_t len)
{
	const char *ptr;
	const char *mime_type;

	ptr = filename + len;
	while (--ptr > filename) {
		if (*ptr == '.') {
			if ((mime_type = configuration_get_value (&mime_types, ptr + 1, NULL)) != NULL) {
				return mime_type;
			}

			break;
		}
	}

	return "application/octet-stream";
}
